unit dmcw_Subject;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, dmModule, DB, FR_DSet, FR_DBSet, ADODB, DateUtils;

type
  Tdtmcw_Subject = class(TdtmModule)
    adsSubType: TADODataSet;
    adsMasterEditRemark2: TStringField;
    adsMasterEditWriter2: TStringField;
    adsMasterEditWriteTime2: TDateTimeField;
    adsMasterEditModifyTime2: TDateTimeField;
    adsMasterEditModifier2: TStringField;
    adsMasterEditHasCheck2: TBooleanField;
    adsMasterEditCheckTime2: TDateTimeField;
    adsMasterEditChecker2: TStringField;
    adsMasterHasCheck: TBooleanField;
    adsMasterChecker: TStringField;
    adsMasterCheckTime: TDateTimeField;
    adsMasterWriter: TStringField;
    adsMasterWriteTime: TDateTimeField;
    adsMasterModifier: TStringField;
    adsMasterModifyTime: TDateTimeField;
    adsMasterRemark: TStringField;
    adsMasterEditSubID: TStringField;
    adsMasterEditSubCode: TStringField;
    adsMasterEditSubFullName: TStringField;
    adsMasterEditSubShortName: TStringField;
    adsMasterEditSubType: TWordField;
    adsMasterEditHasUse: TBooleanField;
    adsMasterEditHasSysDefine: TBooleanField;
    adsMasterEditHasDefault: TBooleanField;
    adsMasterSubID: TStringField;
    adsMasterSubCode: TStringField;
    adsMasterSubFullName: TStringField;
    adsMasterSubShortName: TStringField;
    adsMasterSubType: TWordField;
    adsMasterHasUse: TBooleanField;
    adsMasterHasSysDefine: TBooleanField;
    adsMasterHasDefault: TBooleanField;
    procedure adsMasterEditNewRecord(DataSet: TDataSet);
  private
    { Private declarations }
  protected
    procedure ModuleInit;override;
    procedure OpenEditDataSet; override;
  public
    { Public declarations }
    FSubType: string;
  end;

var
  dtmcw_Subject: Tdtmcw_Subject;

implementation

uses uMsgBox;

{$R *.dfm}

{ Tdtmcw_Subject }

procedure Tdtmcw_Subject.ModuleInit;
begin
  FUniqueTable := 'cw_Subject';
  inherited;
end;  

procedure Tdtmcw_Subject.OpenEditDataSet;
begin
  FMasterEditTable := 'cw_Subject';
  FMasterKeyField := 'SubID';
  inherited;
end;

procedure Tdtmcw_Subject.adsMasterEditNewRecord(DataSet: TDataSet);
begin
  inherited;
  if (adsMasterEdit.State in [dsInsert, dsEdit]) and (FSubType<>'') then
  begin
    DataSet.FieldByName('SubType').ReadOnly := False;
    DataSet.FieldByName('SubType').AsString := FSubType;
  end;
end;

end.

